from django.contrib.auth.models import User
from django.db import models

# Create your models here.

# todo 创建模型
# python .\manage.py makemigrations
# python .\manage.py sqlmigrate moments 0001
# python .\manage.py migrate
class WeChatUser(models.Model):
    # 如何填写
    user = models.OneToOneField(User, models.CASCADE)
    pic = models.CharField(max_length=100, blank=True, null=True)
    motto = models.CharField(max_length=100, blank=True, null=True)
    region = models.CharField(max_length=100, blank=True, null=True)

    def __str__(self):
        return self.user.username
class Status(models.Model):
    user = models.ForeignKey(WeChatUser, models.CASCADE)
    text = models.CharField(max_length=250, blank=True, null=True)
    pub_date = models.DateTimeField(auto_now_add=True)
    pics = models.CharField(max_length=120, blank=True, null=True)

    def __str__(self):
        return self.text
    # 定义元数据
    class Meta:
        ordering = ['id']